import request from 'alinesno-ui/src/utils/request'

var prefix = 'com/alinesno/cloud/initializr/db/database/';
var managerUrl = {
  datatables: prefix + "datatables",
  createUrl: prefix + 'add',
  saveUrl: prefix + 'save',
  checkUrl: prefix + 'checkDB',
  updateUrl: prefix + "modify",
  statusUrl: prefix + "changeStatus",
  cleanUrl: prefix + "clean",
  detailUrl: prefix + "detail",
  removeUrl: prefix + "delete",
  exportUrl: prefix + "exportExcel",
  syncDataBase: prefix + "syncDataBase",
  databaseList: prefix + "databaseList",
}

// 查询用户管理列表
export function listCasLoginRecord(query) {
  return request({
    url: managerUrl.datatables,
    method: 'post',
    params: query
  })
}

//检查配置
export function checkDbConfig(data) {
  return request({
    url: managerUrl.checkUrl,
    method: 'post',
    data: data
  })
}

// 查询用户管理详细
export function getCasLoginRecord(id) {
  return request({
    url: managerUrl.detailUrl + '/' + id,
    method: 'get'
  })
}

// 新增用户管理
export function addCasLoginRecord(data) {
  return request({
    url: managerUrl.saveUrl,
    method: 'post',
    data: data
  })
}

// 修改用户管理
export function updateCasLoginRecord(data) {
  return request({
    url: managerUrl.updateUrl,
    method: 'put',
    data: data
  })
}

// 删除用户管理
export function delCasLoginRecord(id) {
  return request({
    url: managerUrl.removeUrl + '/' + id,
    method: 'delete'
  })
}

// 导出用户管理
export function exportCasLoginRecord(query) {
  return request({
    url: managerUrl.exportUrl,
    method: 'get',
    params: query
  })
}

// 状态修改
export function changeStatusCasLoginRecord(id, status) {
  const data = {
    id,
    status
  }
  return request({
    url: managerUrl.statusUrl,
    method: 'put',
    data: data
  })
}

// 同步数据库
export function syncDataBase(id) {
  return request({
    url: prefix + 'syncDataBase/' + id,
    timeout: 45000,
    method: 'get'
  })
}


// 查询用户数据库
export function databaseList() {
  return request({
    url: managerUrl.databaseList,
    method: 'get',
  })
}

